package Zuoye.zuoye4;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个生日：");
        String s = sc.next();
        //旧
        System.out.println("请输入第二个生日：");
        String s1 = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date ss = sdf.parse(s);
        Date es = sdf.parse(s1);
        if (ss.getTime()>es.getTime()) {
            System.out.println("第一个年龄小");
        } else if (ss.getTime()<es.getTime()){
            System.out.println("第二个年龄小");
        }else {
            System.out.println("一样大");
        }
        //新
        System.out.println("--------------------");
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime aa = LocalDateTime.parse(s,dtf);
        LocalDateTime bb = LocalDateTime.parse(s1,dtf);
        if (aa.isAfter(bb)){
            System.out.println("第一个年龄小");
        }else if (aa.isBefore(bb)){
            System.out.println("第二个年龄小");
        }else {
            System.out.println("一样大");
        }
    }
}
